<?php
require_once 'start.php';

$request = new \lib\Request();
$codeUrl = 'https://ssl.ptlogin2.qq.com/ptqrshow?appid=501004106&e=2&l=M&s=3&d=72&v=4&t=0.7142222046666664&daid=164&pt_3rd_aid=0';
$referer = 'https://xui.ptlogin2.qq.com/cgi-bin/xlogin?daid=164&target=self&style=40&pt_disable_pwd=1&mibao_css=m_webqq&appid=501004106&enable_qlogin=0&no_verifyimg=1&s_url=https://web2.qq.com/proxy.html&f_url=loginerroralert&strong_login=1&login_state=10&t=20131024001';
$response = $request->url($codeUrl)->setReferer($referer)->autoCookie()->send();

$fileList = scandir(ROOT_PATH . DS . 'cookie');
if(isset($fileList['2'])){
    $content = file_get_contents(ROOT_PATH . DS . 'cookie' . DS . $fileList['2']);
    if(preg_match('/qrsig\s(\S*)/', $content, $match)){
        $match[1] = preg_replace('/\s/', '', $match[1]);
        setcookie('qsig', $match[1]);
    }
}

header('Content-Type: image/png');
echo $response;
exit;